package com.cuitrip.storage.prefrence;

import android.content.Context;
import android.content.SharedPreferences;

import com.lab.rtenvironment.AppCoreRuntime;

public class CachePreferenceInstance {


    static final String KEY_CACHE = "cache_info";

    private static CachePreferenceInstance sInstance;
    private static SharedPreferences sp;

    private CachePreferenceInstance() {
    }

    public synchronized static CachePreferenceInstance getInstance() {
        if (sInstance == null) {
            sInstance = new CachePreferenceInstance();
            sp = AppCoreRuntime.context.getSharedPreferences(KEY_CACHE, Context.MODE_PRIVATE);
        }
        return sInstance;
    }

    public String read(String key) {
        return sp.getString(key,"");
    }

    public void write(String key, String value){
        sp.edit().putString(key,value).commit();
    }

    public boolean containsKey(String key){
        return sp.contains(key);
    }


    public void clearAll(String key){
        sp.edit().clear();
    }




}
